module("Examples from the documentation ", {
  setup : function() {
  	Assert.assertsOn();
  	Logger.level(Logger.DEBUG);
  	lastLog = null;
  },
  teardown: function() {
  	Assert.assertsOff();
    lastLog = null;
  }
});

test("devtools.js Docs ", function() {
	
	var testMessage = "this is a test";
	Logger.debug(testMessage);
	
	equal(testMessage, lastLog);
});


test("types.js Docs ", function() {
	
	(function() {
		//now js.mypackage.MyInterface is available on the global namespace
		Types.exportInterface("js.mypackage.MyInterface", {
			aMethod1:function(arg1, arg2) {},
			aMethod2:function(arg1, arg2) {}
		});
	})();

	ok( typeof js.mypackage.MyInterface === 'object');

	(function() {
		var MyObject1 = {
			aMethod1:function(arg1, arg2) {} //missing a method
		}
		var MyObject2 = {
			aMethod1:function(arg1) {}, //missing an argument
			aMethod2:function(arg1, arg2) {}
		}
		var MyObject3 = {
			aMethod1:function(arg1, arg2) {}, 
			aMethod2:function(arg1, arg2, arg3) {} //too many arguments
		}
		
		//these would all fail!
		//Assert.assert(MyObject1.doesImplement(js.mypackage.MyInterface));
		//Assert.assert(MyObject2.doesImplement(js.mypackage.MyInterface));
		//Assert.assert(MyObject3.doesImplement(js.mypackage.MyInterface));
		
		throws(function() {
			Assert.assert(Types.doesImplement(MyObject1, js.mypackage.MyInterface));
		});
		throws(function() {
			Assert.assert(Types.doesImplement(MyObject2, js.mypackage.MyInterface));
		});
		throws(function() {
			Assert.assert(Types.doesImplement(MyObject3, js.mypackage.MyInterface));
		});
		
		var AnotherObject = {
			aMethod1:function(arg1, arg2) {},
			aMethod2:function(arg1, arg2) {},
			anotherMethod:function(arg1) {}
		}
		
		//but this doesn't fail, and allows you to verify that your 'class' is correctly implemented
		Assert.assert(Types.doesImplement(AnotherObject, js.mypackage.MyInterface));
		Types.exportSymbol("js.mypackage.AnotherObject", AnotherObject);
	})();

	(function() {
		var MyObject1 = {
			abstractMethod2:function(arg1, arg2) {} //missing a method
		}
		var MyObject2 = {
			abstractMethod1:function(arg1) {}, //missing an argument
			abstractMethod2:function(arg1, arg2) {}
		}
		var MyObject3 = {
			abstractMethod1:function(arg1, arg2) {}, 
			abstractMethod2:function(arg1, arg2, arg3) {} //too many arguments
		}
		
	})();

});
